<style>
    iframe {
        border-width: 0px;

    }
    .c_box{
        margin:5px;
        cursor: pointer;
    }
    .cur{
        color:red;
    }

</style>
<div class="content">
    <div class="panel panel-default panel-intro">
        <div class="panel-body">
            <div id="" class="tab-content">
                <div class="tab-pane fade active in" id="one">
                    <div class="widget-body no-padding">
                        <div class="bootstrap-table">
                            <div class="fixed-table-toolbar">
                                <div class="bs-bars pull-left" style="width:100%;">
                                    <div id="toolbar" class="toolbar" style="position: relative;">
                                    自定义标签:<input type="text" style="width:160px;height:36px;line-height:36px;border:1px solid #ccc;padding-left:5px;" id="custom">
                                        <a href="javascript:void;" class="btn btn-success btn-add " title="添加"  onclick="customAdd();">
                                            <i class="fa fa-plus"></i> 添加
                                        </a>
                                    </div>

                                    <div style="margin-bottom: 5px; margin-top: 20px;">
                                        {volist name="type" id="type_mark" key="k"}
                                        <a href="/admin/product/index_mark?id={$pid}&type={$k-1}" class="c_box {if condition='$search eq $k-1'}cur{/if}">{$type_mark}</a>
                                        {/volist}
                                    </div>




                                </div>
                                <div>
                                    <div style="width:47%;float:left;">
                                        <table  class="table table-striped table-bordered table-hover table-nowrap" data-operate-edit="1">
                                            <thead>
                                            <tr>
                                                <th class="bs-checkbox " style="text-align: center; vertical-align: middle;width:10%;height: 45px;" data-field="0">ID</th>
                                                <th style="text-align: center; vertical-align: middle;width:80%;" data-field="id">
                                                    <div class="th-inner ">可选标签</div>
                                                    <div class="fht-cell"></div>
                                                </th>
                                                <th style="text-align: center; vertical-align: middle;width:10%;" data-field="id">
                                                    <div class="th-inner ">操作</div>
                                                    <div class="fht-cell"></div>
                                                </th>

                                            </tr>
                                            </thead>
                                            <tbody data-listidx="0">
                                            {volist name="list" id="vo"}
                                            <tr data-index="0">
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.id}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.mark_info}</td>
                                                <td style="text-align: center; vertical-align: middle; ">
                                                    <span class="btn btn-success btn-add add_product" onclick="markAdd('{$vo.id}');">添加</span>
                                                </td>
                                            </tr>
                                            {/volist}
                                            </tbody>
                                        </table>
                                        <div>{$list->render();}</div>
                                    </div>
                                    <div style="width:47%;float:right;" id="divR">
                                        <iframe id="c_p_select"   height="1000px"; width="100%"  border="0"src="/admin/product/index_product_mark?pid={$pid}&type=0">

                                        </iframe>
                                    </div>
                                    <div style="clear:both"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>
<script>
    function markAdd(id){
        //alert(id);
        var pid="{$pid}";
        var flag=1;
        $.ajax({
            url:"/admin/product/markAdd",
            type:'post',
            data:{"id":id,"pid":pid,"flag":flag},
            datatype:'json',
            success:function(data){
                var url="/admin/product/index_product_mark?pid={$pid}&type=0";
                if(data==1){
                    $("#c_p_select").attr("src",url);
                }else if(data==2){
                    alert("该数据已存在");
                }else{
                    alert("添加失败");
                }

            }
        })
    }

    function customAdd(){
        var pid="{$pid}";
        var info=$("#custom").val();
        var flag=0;
        if(info==''){
            alert("自定义标签不得为空");
            return false;
        }
        //alert(info);
        $.ajax({
            url:'/admin/product/markAdd',
            type:'post',
            datatype:'json',
            data:{"info":info,"pid":pid,"flag":flag},
            success:function(data){
                var url="/admin/product/index_product_mark?pid={$pid}&type=0";
                if(data==1){
                    $("#c_p_select").attr("src",url);
                }else if(data==2){
                    alert("该数据已存在");
                }else{
                    alert("添加失败");
                }
            }
        })
    }

</script>
<script>

</script>